﻿// Decompiled with JetBrains decompiler
// Type: DynamicClipping.CUiDynDynamicClippingSettingsCmd
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using DnProcessSimulateCommands.DynamicClipping;
using System.Windows.Forms;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.Ui;


namespace DynamicClipping;

public sealed class CUiDynDynamicClippingSettingsCmd : TxButtonCommand
{
  private CUiDynDynamicClippingForm m_dynamicClippingForm;
  private bool m_active;
  private CApDynDynamicClippingSettingsEnabler m_enabler;

  public CUiDynDynamicClippingSettingsCmd()
  {
    this.m_enabler = new CApDynDynamicClippingSettingsEnabler();
    this.SetStayEnabledInSemiModalMode(true);
  }

  public virtual string Tooltip => DynamicClippingStringTable.CMD_SETTINGS_NAME;

  public virtual string Category => DynamicClippingStringTable.CMD_SETTINGS_CATEGORY;

  public virtual void Execute(object cmdParams)
  {
    if (!this.m_active)
    {
      this.m_dynamicClippingForm = new CUiDynDynamicClippingForm();
      ((Form) this.m_dynamicClippingForm).FormClosed += new FormClosedEventHandler(this.dynamicClippingForm_FormClosed);
      this.m_active = true;
      ((Control) this.m_dynamicClippingForm).Show();
    }
    else
    {
      ((Form) this.m_dynamicClippingForm).FormClosed -= new FormClosedEventHandler(this.dynamicClippingForm_FormClosed);
      this.m_active = false;
      ((Form) this.m_dynamicClippingForm).Close();
      this.m_dynamicClippingForm = (CUiDynDynamicClippingForm) null;
    }
  }

  private void dynamicClippingForm_FormClosed(object sender, FormClosedEventArgs e)
  {
    this.m_active = false;
    this.m_dynamicClippingForm = (CUiDynDynamicClippingForm) null;
  }

  public virtual string Name => DynamicClippingStringTable.CMD_SETTINGS_NAME;

  public virtual string Description => DynamicClippingStringTable.CMD_SETTINGS_DESCRIPTION;

  public virtual string Bitmap => "DynamicClipping.DynamicClipping.bmp";

  public virtual string LargeBitmap => "DynamicClipping.DynamicClipping_LARGE.png";

  public virtual bool Licensed => TxCommandLicenser.DynamicClippingLicense;

  public virtual ITxCommandEnabler CommandEnabler => (ITxCommandEnabler) this.m_enabler;

  public virtual ITxImage Image
  {
    get => (ITxImage) TxImageManager.GetImageByKey("DynamicClippingPlaneSettings");
  }
}
